﻿using System;
using System.Collections.Generic;
using System.Text;
using YouHP.Utility;
using YouHP.BLL;

namespace YouHP.Pages
{
    public class Invite : BasePage
    {
        protected override void ShowPage()
        {
            base.ShowPage();
            this.SetTitle("邀请病友");
            //this.AddLocation("用户注册", "/User/Register.aspx");
            this.AddLocation("邀请病友", "/support/Alpha/Invite.aspx");
            //this.AddLinkCss("/support/Alpha/css/reg.css");

            if (RequestTools.IsPost())
            {
                HandlePost();
            }
        }

        protected void HandlePost()
        {

            string mailLists = RequestTools.GetString("emailLists");
            string mailContent = RequestTools.GetString("messageContent");
            string mailInviter = RequestTools.GetString("inviter");
            string splitString = "\r\n";
            char[] splitArray = splitString.ToCharArray();
            string[] mailArray = mailLists.Split(splitArray);
            bool successed = UserBLL.Instance.SendInviteMail(mailArray, mailContent, mailInviter);
            if (successed)
            {
                AddMsgLine("发送邀请成功");
                SetUrl("/Invite.aspx");
                SetMetaRefresh();
            }
        }
    }
}
